#include "CPlayer.h"


CPlayer::CPlayer(void)
{
	//1 secundend 1 shirheg buudalt hiine
	ShootDeltaTime = 1000;
}

bool CPlayer::OnLoad(char* File, int Width, int Height, int MaxFrames)
{
	if(CEntity::OnLoad(File, Width, Height, MaxFrames) == false)
		return false;

	return true;
}
void CPlayer::OnLoop()
{
	CEntity::OnLoop();
}
void CPlayer::Render(SDL_Surface* Surf_Display)
{
	CEntity::OnRender(Surf_Display);
}
void CPlayer::OnCleanup()
{
	CEntity::OnCleanup();
}
void CPlayer::OnAnimate()
{
	if(SpeedX != 0)
		Anim_Control.MaxFrames = 8;
	else
		Anim_Control.MaxFrames = 0;


	CEntity::OnAnimate();
}
bool CPlayer::OnCollision(CEntity* Entity)
{
	Jump();

	return true;
}

void CPlayer::Shoot()
{
	//Weapon->Shoot();

	if(LastShootTime + ShootDeltaTime < SDL_GetTicks())
	{
		CBullet bullet;
		bullet.OnLoad("./gfx/Bullet.png",10,10,0);
		bullet.X = this->X+2;
		bullet.Y = this->Y+5;
		CEntity::EntityList.push_back(&bullet);

		LastShootTime = SDL_GetTicks();
	}	
}

bool CPlayer::SetWeapon(CWeapon* Weapon){
	if(Weapon == nullptr)
		return false;

	this->Weapon = Weapon;

	return true;
}